<?php

class Social_Controller_Admincp_Browse_Edit extends Nuo_Controller_Admincp
{

	function execute($request)
	{

		Nuo::setVar('breadcrum', array(
			'title'=>'Social Connect',
			'links' => array(
				'admincp' => 'AdminCP',
				'admincp/social' => 'Social Connect'
			),
			'toolbar' => 'admincp/social'
		));

		$table = Nuo::getTable('social/service');

		$id = $request -> getParam('service_id');

		$item = $table -> find($id) -> current();

		$form = Nuo::getObject('social/admincp/browse/' . $id, 'form');

		if ($item && $request -> isGet())
		{
			$form -> populate($item);
		}

		if ($request -> isPost() && $form -> isValid($_POST))
		{
			$data = $form -> getData();

			$form -> commit($item, $data);

			return  array('jscript' => 'nuo.refresh()');

			Nuo_Cache::instance()-> remove('social:getServices');

			return;

		}

		return  Nuo::getView()->render('core/view/controller/admincp/edit', array('form' => $form));
	}

}
